/*
* Copyright (C) Microsoft. All rights reserved.  
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not 
* use this file except in compliance with the License.  You may obtain a copy 
* of the License at http://www.apache.org/licenses/LICENSE-2.0  
* 
* THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 
* WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 
* MERCHANTABLITY OR NON-INFRINGEMENT. 
*
* See the Apache License, Version 2.0 for specific language governing 
* permissions and limitations under the License.
*
*/
#pragma once

#include <baja/common.hpp>
#include <baja/diagnostics_config.hpp>
#include <baja/trace.hpp>
#include <baja/callstack_fwd.hpp>

#pragma push_macro("NO_CALLSTACK")
#define NO_CALLSTACK

#if defined(BAJA_WIN32)
#ifndef _M_IX86
// TRACK: 343: #pragma message("baja/callstack.hpp: callstack support only available for X86 platform")
#else
#if defined(BAJA_DEBUG) // for winrt as well as non winrt...
#if WINAPI_FAMILY != 2
#undef NO_CALLSTACK
#include <baja/callstack_win32.hpp>
#endif
#endif // BAJA_DEBUG
#endif // !_M_IX86
#endif // BAJA_WIN32

#ifdef NO_CALLSTACK
namespace baja 
{
struct callstack
{
    static std::string trace(int32 skipCount = -1, int32 totalCount = -1, bool noThrow = false)
    {
        return std::string("strack trace not available");
    }
};
} // namespace baja
#endif
#pragma pop_macro("NO_CALLSTACK")

namespace baja
{
    BAJA_INLINE std::string getStackTrace(int32 skipCount, int32 totalCount, bool noThrow)
    {
        return callstack::trace(skipCount, totalCount, noThrow);
    }
} // namespace baja